﻿
    <style>

        .szhl_getPeoples {
            display: none;
        }
    </style>
    <script type="text/javascript">

        var tempindex = avalon.define({
            $id: "PDSZ",
            InitWigetData: function () {
                tempindex.GetLIST();
            },
            DelProcess: function (item) {
                //top.ComFunJS.winconfirm("确认要删除吗？(相关表单信息将全部删除)", function () {
                top.ComFunJS.winconfirm("<span style='color:red'>确定要删除吗，删除之后相关表单信息会一起删除？</span>", function () {
                    $.post("/API/VIEWAPI.ashx", { Action: "LCSP_DELLC", P1: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            top.ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.ListData.remove(item);
                            top.ComFunJS.winsuccess("删除成功");
                        }
                    })
                }, function () { })
            },
            setLCSZ: function (ID) {
                top.ComFunJS.winviewform("/ViewV5/Base/APP_WF_LCSZ.html?PDID=" + ID, "设置流程", "1000", "600");
            },
            setLCTEMP: function (ID) {
                top.ComFunJS.winviewform("/ViewV5/Base/ExtendSet.html?PDID=" + ID, "设置模板", "1000", "600");
            },
            SetColumnStatus: function (dom, item) {
                if (confirm("确定要" + $.trim($(dom).html()) + "“" + item.ProcessName + "”吗？")) {
                    $.post("/API/VIEWAPI.ashx", { Action: "LCSP_MODIFYLCSTATE", P1: $.trim($(dom).html()) == "禁用" ? "N" : "Y", P2: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            top.ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            top.ComFunJS.winsuccess($(dom).text() + "“" + item.ProcessName + "”成功");
                            $(dom).html($.trim($(dom).html()) == "禁用" ? "启用" : "禁用");
                        }
                    })
                }
            },
            manageUser: "",
            SetManageUser: function () {
                $.post("/API/VIEWAPI.ashx", { Action: "LCSP_SETMANAGEUSER", P1: model.ListData[tempindex.ManageIndex].ID, P2: tempindex.manageUser }, function (result) {
                    var jsonresult = $.parseJSON(result)
                    if ($.trim(jsonresult.ErrorMsg) != "") {
                        top.ComFunJS.winwarning(jsonresult.ErrorMsg);
                    } else {
                        model.ListData[tempindex.ManageIndex].ManageUser = tempindex.manageUser;
                        top.ComFunJS.winsuccess("保存成功");
                        $("#ManageUserModal").modal("hide");
                    }
                })
            },
            ManageIndex: -1,
            OpenManageUser: function (index) {
                tempindex.manageUser = model.ListData[index].ManageUser;
                ComFunJS.initForm();
                tempindex.ManageIndex = index;
                $("#ManageUserModal").modal("show");
            },
            GetLIST: function () {
                $.getJSON('/API/VIEWAPI.ashx?Action=LCSP_GETWFPDLIST', { Content: model.search.searchcontent }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.ListData = resultData.Result;
                    }
                })
            }

        });
        //@ sourceURL=PDSZ.js;
    </script>


    <div  id="dvContent" ms-controller="PDSZ">
        <div class="btn-add">
            <button type="button" class="btn btn-info btn-lg" ms-click="AddView('LCSP_PROCESS')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加工作流表单模板</button>
        </div>
        <div class="tab-filter-type">
            <!-- 搜索 -->
            <div class="oh">
                <div class="input-group ml15" style="width:295px;">
                    <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索表单名称">
                    <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
                </div>
            </div>
        </div>
        <div class="default-tab ft14 pt20">
            <table class="table table-striped table-responsive table-hover" >
                <thead>
                    <tr>
                        <th class="tc width-70">序号</th>
                        <th>表单名称</th>
                        <th style="width:400px;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-item="ListData">
                        <th class="tc ">{{$index+1}}</th>
                        <td>{{item.ProcessName}}</td>
                        <td>
                            <a href="javascript:void(0);" ms-click="EditForm('LCSP_PROCESS',item.ID,'',$event)" ms-if="item.lcstatus==1">编辑</a>
                            <a href="javascript:void(0);" style="color:red; margin-left:10px;" ms-click="DelProcess(item)" ms-if="item.lcstatus==1">删除</a>
                            <a href="javascript:void(0);" style="color:#FF7F24; margin-left:10px" ms-click="SetColumnStatus(this,item)" ms-if="item.lcstatus==1">{{item.IsSuspended=="Y"?"禁用":"启用"}} </a>
                            <a href="javascript:void(0);" style="color:green; margin-left:10px" ms-click="setLCSZ(item.ID)">设置流程</a>
                            <a href="javascript:void(0);" style="color:green; margin-left:10px" ms-if="item.lcstatus==1" ms-click="setLCTEMP(item.ID)">设置模板</a>
                            <a href="javascript:void(0);" style="color:green; margin-left:10px" ms-if="item.lcstatus==1" ms-click="OpenManageUser($index)">设置可见范围</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="modal fade" id="ManageUserModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 500px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">设置可见范围</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-xs-4 control-label">可查看人员</label>
                                <input type="text" class="form-control szhl_getPeoples" ms-duplex="manageUser" />
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-success" id="conaddForder" ms-click="SetManageUser()">确&nbsp;&nbsp;认</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    

